package com.firebugsoft.spring.cloud.hystrix.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@Service
public class HystrixService{
    @Resource
    private RestTemplate restTemplate;

    @HystrixCommand(fallbackMethod = "fallback")
    public String serviceMonitorEnv(Long sleep) {
        return restTemplate.getForObject("http://spring-cloud-service/service/monitor/env?sleep="+sleep, String.class);
    }

    public String fallback(Long sleep) {
        return "fallback";
    }
}
